<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Minim : : Multiplier</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="stylesheet.css" rel="stylesheet" type="text/css">
</head>
<body> 
<center>
<table class="mainTable">
  <tr>
    <td class="header">
    	<span class="indexheader">Minim</span><br/>
    	<span class="indexnavigation">
    		<a href="index.html">core</a> | 
    		<a href="index_ugens.html">ugens</a> | 
    		<a href="index_analysis.html">analysis</a>
    	</span>
    </td>
    <td class="border-left">&nbsp;</td>
  </tr>
  
  <tr>
    <td class="classNavigation">
    	<p class="mainTextName">Multiplier</p>
    	
       <p class="linkListHeader">Fields</p>
       <p class="linkList">
           
    <a href="multiplier_field_amplitude.html" title="The amplitude input allows you to control the value being used for multiplying with another UGen.">amplitude</a><br/>
    
    <a href="multiplier_field_audio.html" title="The audio input is where incoming audio should be patched, but you can simply patch to the 
 Multiplier itself.">audio</a><br/>
    
	   </p>
   
    	
       <p class="linkListHeader">Methods</p>
       <p class="linkList">
           
    <a href="multiplier_method_channelcount.html" title="Returns the number of channels this UGen has been configured to generate.">channelCount ( )</a><br/>
    
    <a href="multiplier_method_getlastvalues.html" title="Return the last values generated by this UGen. This will most often be
 used by sub-classes when pulling data from their inputs.">getLastValues ( )</a><br/>
    
    <a href="multiplier_method_patch.html" title="Send the output of this UGen to another UGen, UGenInput, or AudioOutput.">patch ( )</a><br/>
    
    <a href="multiplier_method_printinputs.html" title="Prints all inputs connected to this UGen (for debugging)">printInputs ( )</a><br/>
    
    <a href="multiplier_method_samplerate.html" title="Returns the sample rate of this UGen.">sampleRate ( )</a><br/>
    
    <a href="multiplier_method_setchannelcount.html" title="Let this UGen know how many channels of audio you will be asking it for.">setChannelCount ( )</a><br/>
    
    <a href="multiplier_method_setsamplerate.html" title="Set the sample rate for this UGen.">setSampleRate ( )</a><br/>
    
    <a href="multiplier_method_setvalue.html" title="Set the amplitude of this Multiplier.">setValue ( )</a><br/>
    
    <a href="multiplier_method_tick.html" title="Generates one sample frame for this UGen.">tick ( )</a><br/>
    
    <a href="multiplier_method_unpatch.html" title="Unpatch this UGen from an AudioOutput or other UGen.">unpatch ( )</a><br/>
    
	   </p>
   
    </td>
    <td class="mainText border-left">
    	Multiplier is a UGen that will simply multiply the incoming signal by whatever 
 its amplitude input is currently generating, which could be constant if 
 nothing is patched to it.
    	<p class="memberSectionHeader">Constructors</p>
    	<pre><em>Construct a Multiplier with a fixed value of 1, which will mean incoming audio is not changed.</em>
Multiplier()
<em>Construct a Multiplier with a fixed value.</em>
Multiplier(float value)
</pre>
    	
   <p class="memberSectionHeader">Parameters</p>
   
        <span class="parameterName">value</span>&nbsp;&mdash;&nbsp;<span class="parameterDescription">float: the amplitude for the Multiplier</span><br/>
    
   
    	<p class="memberSectionHeader">Related</p>
    	<A href="ugen_class_ugen.html">UGen</A><BR>

    	<p class="memberSectionHeader">Example</p>
    	<pre>/**
  This is an example of using a Multiplier UGen, which performs the very simple operation of 
  multiplying the incoming signal by the current value of its amplitude input.
  &lt;p>
  Move the mouse left and right to change the value of the Multiplier. 
  All the way left is 0.1 and all the way right is 1.
  &lt;p>
  For more information about Minim and additional features,&lt;br/>
  visit http://code.compartmental.net/minim/
  &lt;p>
  author: Damien Di Fede
*/

import ddf.minim.*;
import ddf.minim.ugens.*;

Minim         minim;
AudioOutput   out;
Oscil         osc;
Multiplier    multiplier;

void setup()
{
  // setup the size of the app
  size(640, 200);
  
  // create our Minim object for loading audio
  minim = new Minim(this);
  
  // get a line out from Minim. It's important that the file is the same audio format 
  // as our output (i.e. same sample rate, number of channels, etc).
  out = minim.getLineOut();
  
  osc = new Oscil( 440, 1 );
  multiplier = new Multiplier( 0.5f );
  
  // normally we wouldn't use a multiplier with an Oscil like this
  // because we could simply set the amplitude of the Oscil itself.
  osc.patch( multiplier ).patch( out );
                        
}

// draw is run many times
void draw()
{
  // map the mouse position to a new value for the multiplier
  float value = map(mouseX, 0, width, 0.1, 1);
  
  // set the new value.
  // this is equivalent to multiplier.amplitude.setLastValue( value )
  // you'll also notice this causes audible clicks if you move the mouse quickly
  // to keep that from happening, you will usually want to use a Line patched 
  // to the Multiplier's amplitude input.
  multiplier.setValue( value );
  
  // erase the window to black
  background( 0 );
  // draw using a white stroke
  stroke( 255 );
  // draw the waveforms
  for( int i = 0; i &lt; out.bufferSize() - 1; i++ )
  {
    // find the x position of each buffer value
    float x1  =  map( i, 0, out.bufferSize(), 0, width );
    float x2  =  map( i+1, 0, out.bufferSize(), 0, width );
    // draw a line from one buffer position to the next for both channels
    line( x1, 50 + out.left.get(i)*50, x2, 50 + out.left.get(i+1)*50);
    line( x1, 150 + out.right.get(i)*50, x2, 150 + out.right.get(i+1)*50);
  }  
}

</pre>
    	<p class="memberSectionHeader">Usage</p>
    	Web & Application
    </td>
  </tr>
</table>
</center>
</body>
</html>